package com.example;

import de.greenrobot.daogenerator.DaoGenerator;
import de.greenrobot.daogenerator.Entity;
import de.greenrobot.daogenerator.Schema;

public class MyDao {

    public static void main(String args[]) throws Exception {
        //初始化一下数据库
        //第一个参数是版本号,第二个参数是为你生成的bean类放的文件夹名
        Schema schema = new Schema(1, "greendao");
        //设置一下生成的三个java文件的目录
        schema.setDefaultJavaPackageDao("com.qc.wintrax.db");
//        initUserBean(schema);
        mapAddress(schema);
        mapInfo(schema);
        lineName(schema);
        markerInfo(schema);
        new DaoGenerator().generateAll(schema, "app/src/main/java-gen");
    }

    private static void mapAddress(Schema schema) {
        //建立一个表
        Entity userBean = schema.addEntity("MapAddress");
        userBean.addStringProperty("address");
        userBean.addStringProperty("latitude");
        userBean.addStringProperty("longitude");
    }

    private static void contacts(Schema schema) {
        //建立一个表
        Entity userBean = schema.addEntity("Contacts");
        userBean.addStringProperty("headUrl");
        userBean.addStringProperty("name");
        userBean.addStringProperty("weixin");
        userBean.addStringProperty("email");
        userBean.addStringProperty("QQ");
        userBean.addStringProperty("nickName");
        userBean.addIntProperty("id");
    }

    private static void mapInfo(Schema schema) {
        //建立一个表
        Entity mapInfo = schema.addEntity("MapInfo");
        mapInfo.addStringProperty("map_title");
        mapInfo.addDoubleProperty("map_latitude");
        mapInfo.addDoubleProperty("map_longitude");
        mapInfo.addStringProperty("map_imgUrl");
        mapInfo.addLongProperty("line_id");
        mapInfo.addDoubleProperty("map_altitude");
        mapInfo.addIdProperty();
    }

    private static void lineName(Schema schema) {
        //建立一个表
        Entity mapInfo = schema.addEntity("LineName");
        mapInfo.addStringProperty("map_title");
        mapInfo.addStringProperty("map_distance");
        mapInfo.addStringProperty("map_totalTime");
        mapInfo.addIdProperty();
    }

    private static void markerInfo(Schema schema) {
        //建立一个表
        Entity mapInfo = schema.addEntity("MarkerInfo");
        mapInfo.addStringProperty("marker_titleName");
        mapInfo.addDoubleProperty("marker_latitude");
        mapInfo.addDoubleProperty("marker_longitude");
        mapInfo.addLongProperty("line_id");
        mapInfo.addIdProperty();
    }

}
